package com.gpframework.module.module.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gpframework.common.utils.DateUtils;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.module.domain.GpDeliveryNote;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @ClassName GpDeliveryNoteReq
 * @Author gpframework
 * @Date 2023-12-11
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GpDeliveryNoteReq extends BaseReq {
    private static final long serialVersionUID = 1L;

         @ApiModelProperty("${column.columnComment}")
     private Long id;
     @ApiModelProperty("品牌id")
     private String brandId;
     @ApiModelProperty("品牌名称")
     private String brandName;
     @ApiModelProperty("订单号")
     private String sn;
     @ApiModelProperty("染厂id")
     private Long dyeingFactoryId;
     @ApiModelProperty("染厂名称")
     private String dyeingFactoryName;
     @ApiModelProperty("发货日期")
     private Date sendOutGoodsTime;
     @ApiModelProperty("发货日期（开始）")
     private Date sendOutGoodsStartTime;
     @ApiModelProperty("发货日期（结束）")
     private Date sendOutGoodsEndTime;
     @ApiModelProperty("胚布基础表id")
     private Long supplierGreyClothId;
     @ApiModelProperty("供应商名称")
     private String supplierName;
     @ApiModelProperty("产品基础表id")
     private Long produceProductId;
     @ApiModelProperty("产品名")
     private String productName;
     @ApiModelProperty("颜色")
     private String colour;
     @ApiModelProperty("数量（条数）")
     private Integer quantity;
     @ApiModelProperty("物流基础表id")
     private Long logisticsId;
     @ApiModelProperty("物流")
     private String logistics;
     @ApiModelProperty("批号")
     private String batchNo;
     @ApiModelProperty("缸号")
     private String dyeVatNo;
     @ApiModelProperty("规格")
     private Integer specifications;
     @ApiModelProperty("出厂规格")
     private Integer exFactorySpecifications;
     @ApiModelProperty("总码数")
     private Integer totalQuantity;
     @ApiModelProperty("大小条（码）")
     private Integer sizeBar;
     @ApiModelProperty("包数")
     private Integer packageQuantity;
     @ApiModelProperty("总包数")
     private Integer totalPackageQuantity;
     @ApiModelProperty("实际到货条数")
     private Integer actualArrivalQuantity;
     @ApiModelProperty("是否来料： 0否 1是")
     private String incomingFlag;
     @ApiModelProperty("是否跟踪： 0否 1是")
     private String trackFlag;
     @ApiModelProperty("跟单人id")
     private Long followUpId;
     @ApiModelProperty("跟单人名称")
     private String followUpName;
     @ApiModelProperty("跟单时间")
     private Date followUpTime;
     @ApiModelProperty("收货人id")
     private Long receiveId;
     @ApiModelProperty("收货人名称")
     private String receiveName;
     @ApiModelProperty("收货时间")
     private Date receiveTime;
     @ApiModelProperty("排序")
     private Integer sort;
     @ApiModelProperty("备注")
     private String remarks;
     @ApiModelProperty("创建者")
     private String createBy;
     @ApiModelProperty("创建时间")
     private Date createTime;
    @ApiModelProperty("查询条件（订单号/客户名）")
    private String searchName;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date searchDate;
    /** 操作人编号 */
    private String operatorNum;
    /**审批人名称 */
    private String examinName;
    /**染厂胚布品名 */
    @ApiModelProperty("染厂胚布品名")
    private String dyeingGreyClothName;

    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GpDeliveryNote> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);
            lqw.orderByDesc(alias+"create_time");
        }
        if (this.getId() != null){
        lqw.eq(alias+"id" ,this.getId());
        }
        if (StringUtils.isNotBlank(this.getBrandId())){
        lqw.eq(alias+"brand_id" ,this.getBrandId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())){
            lqw.like(alias+"brand_name",this.getBrandName());
        }
        if (StringUtils.isNotBlank(this.getSn())){
        lqw.eq(alias+"sn" ,this.getSn());
        }
        if (this.getDyeingFactoryId() != null){
        lqw.eq(alias+"dyeing_factory_id" ,this.getDyeingFactoryId());
        }
        if (StringUtils.isNotBlank(this.getDyeingFactoryName())){
            lqw.like(alias+"dyeing_factory_name",this.getDyeingFactoryName());
        }
        if (this.getSendOutGoodsTime() != null){
        lqw.eq(alias+"send_out_goods_time" ,this.getSendOutGoodsTime());
        }
        if (this.getSendOutGoodsStartTime() != null && this.getSendOutGoodsEndTime() != null){
            lqw.between(alias+"send_out_goods_time" ,this.getSendOutGoodsStartTime(), this.getSendOutGoodsEndTime());
        }
        if (this.getSupplierGreyClothId() != null){
        lqw.eq(alias+"supplier_grey_cloth_id" ,this.getSupplierGreyClothId());
        }
        if (StringUtils.isNotBlank(this.getSupplierName())){
            lqw.like(alias+"supplier_name",this.getSupplierName());
        }
        if (this.getProduceProductId() != null){
        lqw.eq(alias+"produce_product_id" ,this.getProduceProductId());
        }
        if (StringUtils.isNotBlank(this.getProductName())){
            lqw.like(alias+"product_name",this.getProductName());
        }
        if (StringUtils.isNotBlank(this.getColour())){
        lqw.like(alias+"colour" ,this.getColour());
        }
        if (this.getQuantity() != null){
        lqw.eq(alias+"quantity" ,this.getQuantity());
        }
        if (this.getLogisticsId() != null){
        lqw.eq(alias+"logistics_id" ,this.getLogisticsId());
        }
        if (StringUtils.isNotBlank(this.getLogistics())){
        lqw.eq(alias+"logistics" ,this.getLogistics());
        }
        if (StringUtils.isNotBlank(this.getBatchNo())){
        lqw.eq(alias+"batch_no" ,this.getBatchNo());
        }
        if (StringUtils.isNotBlank(this.getDyeVatNo())){
        lqw.eq(alias+"dye_vat_no" ,this.getDyeVatNo());
        }
        if (this.getSpecifications()!=null){
        lqw.eq(alias+"specifications" ,this.getSpecifications());
        }
        if (this.getExFactorySpecifications()!=null){
        lqw.eq(alias+"ex_factory_specifications" ,this.getExFactorySpecifications());
        }
        if (this.getTotalQuantity() != null){
        lqw.eq(alias+"total_quantity" ,this.getTotalQuantity());
        }
        if (this.getSizeBar() != null){
        lqw.eq(alias+"size_bar" ,this.getSizeBar());
        }
        if (this.getPackageQuantity() != null){
        lqw.eq(alias+"package_quantity" ,this.getPackageQuantity());
        }
        if (this.getTotalPackageQuantity() != null){
        lqw.eq(alias+"total_package_quantity" ,this.getTotalPackageQuantity());
        }
        if (this.getActualArrivalQuantity() != null){
        lqw.eq(alias+"actual_arrival_quantity" ,this.getActualArrivalQuantity());
        }
        if (StringUtils.isNotBlank(this.getIncomingFlag())){
        lqw.eq(alias+"incoming_flag" ,this.getIncomingFlag());
        }
        if (StringUtils.isNotBlank(this.getTrackFlag())){
        lqw.eq(alias+"track_flag" ,this.getTrackFlag());
        }
        if (this.getFollowUpId() != null){
        lqw.eq(alias+"follow_up_id" ,this.getFollowUpId());
        }
        if (StringUtils.isNotBlank(this.getFollowUpName())){
            lqw.like(alias+"follow_up_name",this.getFollowUpName());
        }
        if (this.getFollowUpTime() != null){
        lqw.eq(alias+"follow_up_time" ,this.getFollowUpTime());
        }
        if (this.getReceiveId() != null){
        lqw.eq(alias+"receive_id" ,this.getReceiveId());
        }
        if (StringUtils.isNotBlank(this.getReceiveName())){
            lqw.like(alias+"receive_name",this.getReceiveName());
        }
        if (this.getReceiveTime() != null){
        lqw.eq(alias+"receive_time" ,this.getReceiveTime());
        }
        if (this.getSort() != null){
        lqw.eq(alias+"sort" ,this.getSort());
        }
        if (StringUtils.isNotBlank(this.getRemarks())){
        lqw.eq(alias+"remarks" ,this.getRemarks());
        }
        if (StringUtils.isNotBlank(this.getCreateBy())){
        lqw.eq(alias+"create_by" ,this.getCreateBy());
        }
        if (this.getCreateTime() != null){
        lqw.eq(alias+"create_time" ,this.getCreateTime());
        }
        if (StringUtils.isNotBlank(this.getSearchName())) {
            lqw.and(wrapper -> wrapper.like("gp.sn", this.getSearchName()).or().like("gp.product_name", this.getSearchName()).or().like("gp.colour", this.getSearchName()));
        }
        if (this.getSearchDate() != null) {
            lqw.apply("DATE_FORMAT(gp.create_time, '%Y-%m-%d') = '" + DateUtils.dateTime(this.getSearchDate()) + "'");
        }
    }
}
